<template>
    <div class="mainBox2">
        <div style="height:40px;">
            <el-col :span="2" :offset="20" style="height:40px;">
                <el-button type="primary"  @click="baoCun">保存</el-button>
            </el-col>
            <el-col :span="2" style="height:40px;">
                <el-button plain @click="tiJiao">提交</el-button>
            </el-col>
        </div>
        <div style="height:30px;"></div>
        <div class="xinZengBox2">
            <div class="stepBar">
                    <el-steps :active="active" align-center>
                        <el-step title="填写基本信息" ></el-step>
                        <el-step title="填写工资待遇" ></el-step>
                        <el-step title="填写住宿饮食" ></el-step> 
                        <el-step title="填写岗位要求" ></el-step>
                        <el-step title="填写录用条件" ></el-step>
                        <el-step title="支付委培定金" ></el-step>
                    </el-steps>
            </div>
            <div style="height:30px;"></div>
            <div v-if="active==1">
                <div class="juZhong" style="height:40px;margin-bottom:10px;">
                    <span style="color:#409EFF">基本信息</span>
                </div>
                <div >
                    <el-form ref="form" :model="form" :label-position="labelPosition" label-width="230px" :rules="step1Rules">
                        <el-form-item label="委培工种"  @change="showTime" prop="professionId" >
                            <el-col :span="14">
                                <el-select v-model="form.professionId" placeholder="请选择" style="width:100%;" @change="getPosition">
                                    <el-option
                                        v-for="item in gongZhongs"
                                        :key="item.professionId"
                                        :label="item.professionName"
                                        :value="item.professionId">
                                    </el-option>
                                </el-select>
                            </el-col>
                            <el-col :span="2" :offset="2">
                                <span style="color:#D9001B;margin-left:10px;">(必填)</span>
                            </el-col>
                        </el-form-item>
                        <el-form-item label="委培职位" prop="positionId" >
                            <el-col :span="14">
                                <el-select v-model="form.positionId" placeholder="请选择" style="width:100%;">
                                    <el-option
                                        v-for="item in zhiWeis"
                                        :key="item.positionId"
                                        :label="item.name"
                                        :value="item.positionId">
                                    </el-option>
                                </el-select>
                            </el-col>
                            <el-col :span="2" :offset="2">
                                <span style="color:#D9001B;margin-left:10px;">(必填)</span>
                            </el-col>
                        </el-form-item>
                        <el-form-item label="委培人数" prop="requirePopulation" >
                            <el-col :span="14">
                                <el-input-number v-model="form.requirePopulation" :min="1" style="width:100%;"></el-input-number>
                            </el-col>
                            <el-col :span="2" style="margin-left:10px;">
                                <span style="color:#707070">人</span>
                            </el-col>
                            <el-col :span="2">
                                <span style="color:#D9001B">(必填)</span>
                            </el-col>
                        </el-form-item>
                        <el-form-item label="联系方式" prop="contact" >
                            <el-col :span="14">
                                <el-input v-model="form.contact" class="xinXi"></el-input>
                            </el-col>
                            <el-col :span="2" :offset="2" >
                                <span style="color:#D9001B;margin-left:10px;">(必填)</span>
                            </el-col>
                        </el-form-item>
                        <el-form-item label="工作地址" prop="address">
                            <el-col :span="14">
                                <el-input v-model="form.address" class="xinXi"></el-input>
                            </el-col>
                            <el-col :span="2" style="margin-left:10px;">
                                <span style="color:#409EFF"><i class="el-icon-location" style="font-size:18px;"></i></span>
                            </el-col>
                            <el-col :span="2">
                                <span style="color:#D9001B">(必填)</span>
                            </el-col>
                        </el-form-item>
                        <el-form-item label="工资水平" prop="minSalary">
                            <el-col :span="5">
                                <el-input-number v-model="form.minSalary" :min="1" style="width:100%;" controls-position="right"></el-input-number>
                            </el-col>
                            <el-col :span="1" style="margin-left:10px;margin-right:10px;">
                                <span style="color:#707070">元</span>
                            </el-col>
                            <el-col :span="1" style="margin-left:10px;margin-right:20px;">
                                <span style="color:#707070">——</span>
                            </el-col>
                            <el-col :span="5">
                                <el-input-number v-model="form.maxSalary" :min="1" style="width:100%;" controls-position="right"></el-input-number>
                            </el-col>
                            <el-col :span="2" style="margin-left:10px;">
                                <span style="color:#707070">元</span>
                            </el-col>
                            <el-col :span="2">
                                <span style="color:#D9001B">(必填)</span>
                            </el-col>
                        </el-form-item>
                        <el-form-item label="委培时间" prop="dateTime1">
                            <el-col :span="14">
                                <el-date-picker
                                    style="width:100%;"
                                    value-format="yyyy-MM-dd HH:mm:ss"
                                    format="yyyy-MM-dd HH:mm:ss"
                                    @change="correctTime"
                                    v-model="form.dateTime1"
                                    type="datetimerange"
                                    :picker-options="pickerOptionsEnd"
                                    start-placeholder="开始日期"
                                    end-placeholder="结束日期"
                                    :default-time="['12:00:00']">
                                </el-date-picker>
                            </el-col>
                            <el-col :span="2" :offset="2">
                                <span style="color:#D9001B;margin-left:10px;">(必填)</span>
                            </el-col>
                        </el-form-item>
                        <el-form-item label="截止时间" prop="deadline">
                            <el-col :span="14">
                                <el-date-picker
                                    class="consginDate"
                                    style="width:100%;"
                                    value-format="yyyy-MM-dd HH:mm:ss"
                                    format="yyyy-MM-dd HH:mm:ss"
                                    v-model="form.deadline"
                                    type="datetime"
                                    placeholder="选择日期时间"
                                    :picker-options="pickerOptionsStart">
                                </el-date-picker>
                            </el-col>
                            <el-col :span="2" :offset="2" >
                                <span style="color:#D9001B;margin-left:10px;">(必填)</span>
                            </el-col>
                        </el-form-item>
                        <el-form-item label="报名要求" prop="applyRequest">
                            <el-col :span="14">
                                <el-input v-model="form.applyRequest" class="xinXi"></el-input>
                            </el-col>
                            <el-col :span="2" :offset="2" >
                                <span style="color:#D9001B;margin-left:10px;">(必填)</span>
                            </el-col>
                        </el-form-item>
                        <el-form-item label="其他说明" prop="otherNotice">
                            <el-col :span="14">
                                <el-input type="textarea" v-model="form.otherNotice" placeholder="若无其他说明请填无"></el-input>
                            </el-col>
                            <el-col :span="2" :offset="2" >
                                <span style="color:#D9001B;margin-left:10px;">(必填)</span>
                            </el-col>
                        </el-form-item>
                    </el-form>
                </div>
                <div class="diBuAnNiu">
                    <span class="juZhong">
                        <el-button type="primary" @click="goToStep2">下一步</el-button>
                    </span>
                </div>
            </div>
            <div v-else-if="active==2">
                <div class="juZhong" style="height:40px;margin-bottom:10px;">
                    <span style="color:#409EFF">工资待遇</span>
                </div>
                <div>
                    <el-form ref="form" :model="form" :label-position="labelPosition" label-width="230px" :rules="step2Rules">
                        <el-form-item label="基本工资" prop="baseSalary" key="baseSalary.id">
                            <el-col :span="14">
                                <el-input-number v-model="form.baseSalary" :min="1" style="width:100%;"></el-input-number>
                            </el-col>
                            <el-col :span="2" style="margin-left:10px;">
                                <span style="color:#707070">元/月</span>
                            </el-col>
                            <el-col :span="2">
                                <span style="color:#D9001B">(必填)</span>
                            </el-col>
                        </el-form-item>
                        <el-form-item label="发薪日期" prop="paySalaryDate" key="paySalaryDate.id">
                            <el-col :span="14">
                                <el-input-number v-model="form.paySalaryDate" :min="1" :max="31" style="width:100%;"></el-input-number>
                            </el-col>
                            <el-col :span="2" style="margin-left:10px;">
                                <span style="color:#707070">号</span>
                            </el-col>
                            <el-col :span="2">
                                <span style="color:#D9001B;">(必填)</span>
                            </el-col>
                        </el-form-item>
                        <el-form-item label="结算方式" prop="payType" key="payType.id">
                            <el-col :span="14">
                                <el-select v-model="form.payType" placeholder="请选择" style="width:100%;">
                                    <el-option
                                        v-for="item in payTypes"
                                        :key="item.value"
                                        :label="item.label"
                                        :value="item.value">
                                    </el-option>
                                </el-select>
                            </el-col>
                            <el-col :span="2" :offset="2" >
                                <span style="color:#D9001B;margin-left:10px;">(必填)</span>
                            </el-col>
                        </el-form-item>
                        <el-form-item label="其他说明" prop="salaryOtherNotice" key="salaryOtherNotice.id">
                            <el-col :span="14">
                                <el-input type="textarea" v-model="form.salaryOtherNotice" placeholder="若无其他说明请填无"></el-input>
                            </el-col>
                            <el-col :span="2" :offset="2" >
                                <span style="color:#D9001B;margin-left:10px;">(必填)</span>
                            </el-col>
                        </el-form-item>
                    </el-form>
                </div>
                <div class="diBuAnNiu2">
                    <span style="margin:10px;">
                        <el-button type="primary" @click="back">上一步</el-button>
                    </span>
                    <span style="margin:10px;">
                        <el-button type="primary" @click="goToStep3">下一步</el-button>
                    </span>
                </div>
            </div>
            <div v-else-if="active==3">
                <div class="juZhong" style="height:40px;margin-bottom:10px;">
                    <span style="color:#409EFF">住宿饮食</span>
                </div>
                <div >  
                    <el-form ref="form" :model="form" :label-position="labelPosition" label-width="230px" :rules="step3Rules">
                        <el-form-item label="住宿说明" prop="liveNotice" key="liveNotice.id">
                            <el-col :span="14">
                                <el-input v-model="form.liveNotice" class="xinXi" placeholder="例：包住，4人间"></el-input>
                            </el-col>
                            <el-col :span="2" :offset="2" >
                                <span style="color:#D9001B;margin-left:10px;">(必填)</span>
                            </el-col>
                        </el-form-item>
                        <el-form-item label="饮食说明" prop="foodNotice" key="foodNotice.id">
                            <el-col :span="14">
                                <el-input v-model="form.foodNotice" class="xinXi"  placeholder="例：包吃三餐"></el-input>
                            </el-col>
                            <el-col :span="2" :offset="2" >
                                <span style="color:#D9001B;margin-left:10px;">(必填)</span>
                            </el-col>
                        </el-form-item>
                        <el-form-item label="社保说明" prop="socialSecurityNotice" key="socialSecurityNotice.id">
                            <el-col :span="14">
                                <el-input v-model="form.socialSecurityNotice" class="xinXi" placeholder="例：五险一金"></el-input>
                            </el-col>
                            <el-col :span="2" :offset="2" >
                                <span style="color:#D9001B;margin-left:10px;">(必填)</span>
                            </el-col>
                        </el-form-item>
                        <el-form-item label="其他说明" prop="liveFoodOtherNotice" key="liveFoodOtherNotice.id">
                            <el-col :span="14">
                                <el-input type="textarea" v-model="form.liveFoodOtherNotice" placeholder="若无其他说明请填无"></el-input>
                            </el-col>
                            <el-col :span="2" :offset="2" >
                                <span style="color:#D9001B;margin-left:10px;">(必填)</span>
                            </el-col>
                        </el-form-item>
                    </el-form>
                </div>
                <div class="diBuAnNiu2">
                    <span style="margin:10px;">
                        <el-button type="primary" @click="back">上一步</el-button>
                    </span>
                    <span style="margin:10px;">
                        <el-button type="primary" @click="goToStep4">下一步</el-button>
                    </span>
                </div>
            </div>
             <div v-else-if="active==4">
                <div class="juZhong" style="height:40px;margin-bottom:10px;">
                    <span style="color:#409EFF">岗位要求</span>
                </div>
                <div >
                    <el-form ref="form" :model="form" :label-position="labelPosition" label-width="230px" :rules="step4Rules">
                        <el-form-item label="工作内容" prop="jobText" key="jobText.id">
                            <el-col :span="14">
                                <el-input v-model="form.jobText" class="xinXi" ></el-input>
                            </el-col>
                            <el-col :span="2" :offset="2" >
                                <span style="color:#D9001B;margin-left:10px;">(必填)</span>
                            </el-col>
                        </el-form-item>
                        <el-form-item label="工作时间" prop="postTime" key="postTime.id">
                            <el-col :span="14">
                                <el-time-picker
                                        @change="correctTime1"
                                        value-format="HH:mm"
                                        format="HH:mm"
                                        is-range
                                        arrow-control
                                        v-model="form.postTime"
                                        range-separator="至"
                                        start-placeholder="开始时间"
                                        end-placeholder="结束时间"
                                        placeholder="选择时间范围"
                                        style="width:100%;"

                                        >
                                </el-time-picker>
                            </el-col>
                            <el-col :span="2" :offset="2" >
                                <span style="color:#D9001B;margin-left:10px;">(必填)</span>
                            </el-col>
                        </el-form-item>
                        <el-form-item label="工作方式" prop="jobWay" key="jobWay.id">
                            <el-col :span="14">
                                <el-input v-model="form.jobWay" class="xinXi" placeholder="例：坐班"></el-input>
                            </el-col>
                            <el-col :span="2" :offset="2" >
                                <span style="color:#D9001B;margin-left:10px;">(必填)</span>
                            </el-col>
                        </el-form-item>
                        <el-form-item label="其他说明" prop="jobOtherNotice" key="jobOtherNotice.id">
                            <el-col :span="14">
                                <el-input type="textarea" v-model="form.jobOtherNotice" placeholder="若无其他说明请填无"></el-input>
                            </el-col>
                            <el-col :span="2" :offset="2" >
                                <span style="color:#D9001B;margin-left:10px;">(必填)</span>
                            </el-col>
                        </el-form-item>
                    </el-form>
                </div>
                <div class="diBuAnNiu2">
                    <span style="margin:10px;">
                        <el-button type="primary" @click="back">上一步</el-button>
                    </span>
                    <span style="margin:10px;">
                        <el-button type="primary" @click="goToStep5">下一步</el-button>
                    </span>
                </div>
            </div>
            <div v-else-if="active==5">
                <div class="juZhong" style="height:40px;margin-bottom:10px;">
                    <span style="color:#409EFF">录用条件</span>
                </div>
                <div >
                    <el-form ref="form" :model="form" :label-position="labelPosition" label-width="230px" :rules="step5Rules">
                        <el-form-item label="性别条件" prop="sexRequest" key="sexRequest.id">
                            <el-col :span="14">
                                <el-select v-model="form.sexRequest" placeholder="请选择" style="width:100%;">
                                    <el-option
                                        v-for="item in xingBies"
                                        :key="item.value"
                                        :label="item.label"
                                        :value="item.value">
                                    </el-option>
                                </el-select>
                            </el-col>
                            <el-col :span="2" :offset="2">
                                <span style="color:#D9001B;margin-left:10px;">(必填)</span>
                            </el-col>
                        </el-form-item>
                        <el-form-item label="年龄条件" prop="minAgeRequest" key="minAgeRequest.id">
                            <el-col :span="5">
                                <el-input-number v-model="form.minAgeRequest" :min="1" style="width:100%;" controls-position="right"></el-input-number>
                            </el-col>
                            <el-col :span="1" style="margin-left:10px;margin-right:10px;">
                                <span style="color:#707070">岁</span>
                            </el-col>
                            <el-col :span="1" style="margin-left:10px;margin-right:20px;">
                                <span style="color:#707070">——</span>
                            </el-col>
                            <el-col :span="5">
                                <el-input-number v-model="form.maxAgeRequest" :min="1" style="width:100%;" controls-position="right"></el-input-number>
                            </el-col>
                            <el-col :span="2" style="margin-left:8px;">
                                <span style="color:#707070">岁</span>
                            </el-col>
                            <el-col :span="2">
                                <span style="color:#D9001B">(必填)</span>
                            </el-col>
                        </el-form-item>
                        <el-form-item label="学历条件" prop="eduBackground" key="eduBackground.id">
                            <el-col :span="14">
                                <el-select v-model="form.eduBackground" placeholder="请选择" style="width:100%;">
                                    <el-option
                                        v-for="item in xueLis"
                                        :key="item.value"
                                        :label="item.label"
                                        :value="item.value">
                                    </el-option>
                                </el-select>
                            </el-col>
                            <el-col :span="2" :offset="2">
                                <span style="color:#D9001B;margin-left:10px;">(必填)</span>
                            </el-col>
                        </el-form-item>
                        <el-form-item label="经验条件" prop="minExpRequest" key="minExpRequest.id">
                            <el-col :span="5">
                                <el-input-number v-model="form.minExpRequest" :min="0" style="width:100%;" controls-position="right"></el-input-number>
                            </el-col>
                            <el-col :span="1" style="margin-left:10px;margin-right:10px;">
                                <span style="color:#707070">年</span>
                            </el-col>
                            <el-col :span="1" style="margin-left:10px;margin-right:20px;">
                                <span style="color:#707070">——</span>
                            </el-col>
                            <el-col :span="5">
                                <el-input-number v-model="form.maxExpRequest" :min="1" style="width:100%;" controls-position="right"></el-input-number>
                            </el-col>
                            <el-col :span="2" style="margin-left:8px;">
                                <span style="color:#707070">年</span>
                            </el-col>
                            <el-col :span="2">
                                <span style="color:#D9001B">(必填)</span>
                            </el-col>
                        </el-form-item>
                        <el-form-item label="证书条件" prop="credentialRequest" key="credentialRequest.id">
                            <el-col :span="14">
                                <el-input v-model="form.credentialRequest" class="xinXi"></el-input>
                            </el-col>
                            <el-col :span="2" :offset="2" >
                                <span style="color:#D9001B;margin-left:10px;">(必填)</span>
                            </el-col>
                        </el-form-item>
                        <el-form-item label="其他说明" prop="employOtherNotice" key="employOtherNotice.id">
                            <el-col :span="14">
                                <el-input type="textarea" v-model="form.employOtherNotice" placeholder="若无其他说明请填无"></el-input>
                            </el-col>
                            <el-col :span="2" :offset="2" >
                                <span style="color:#D9001B;margin-left:10px;">(必填)</span>
                            </el-col>
                        </el-form-item>
                    </el-form>
                </div>
                <div class="diBuAnNiu2">
                    <span style="margin:10px;">
                        <el-button type="primary" @click="back">上一步</el-button>
                    </span>
                    <span style="margin:10px;">
                        <el-button type="primary" @click="goToStep6">下一步</el-button>
                    </span>
                </div>
            </div>
        </div>
        <div class="guiZe">
            <span style="color:#707070;">招聘规则</span>
        </div>
        <el-dialog 
            :visible.sync="dialogVisible"
            width="30%">
                <span>要继续上次编辑吗？</span>
                <span slot="footer" class="dialog-footer">
                    <el-button @click="dialogVisible = false">取 消</el-button>
                    <el-button type="primary" @click="editSaved">确 定</el-button>
                </span>
        </el-dialog>
    </div>    
</template>

<script>
export default {
    data(){
        //校验说明
        var validateNotice= (rule, value, callback) => {            
            if (value === '') {
                callback(new Error('请输入信息'));
            } else if (value.length<4&&value!='无') {
               
                console.log(value);
                callback(new Error('请至少输入4个字,若无说明请填无'));
            } else {
                callback();
            }
        };
        //校验地址等信息
        var validateInformation= (rule, value, callback) => {            
            if (value === '') {
                callback(new Error('请输入信息'));
            } else if (value.length<4) {
               
                console.log(value);
                callback(new Error('请至少输入4个字'));
            } else {
                callback();
            }
        };
        //校验联系方式
        var reg=/^1[3|4|5|7|8][0-9]{9}/;
        var validateContact= (rule, value, callback) => {            
            if (value === '') {
                callback(new Error('请输入联系方式'));
            } else if (!reg.test(value)) {
               
                console.log(value);
                callback(new Error('请输入有效的手机号码'));
            } else {
                callback();
            }
        };
        return{
            pickerOptionsStart: {
                    disabledDate: time => {
                        let endDateVal = this.form.startTime;
                        if (endDateVal) {
                            return time.getTime() > new Date(endDateVal).getTime();
                        }
                    }
            },
            pickerOptionsEnd: {
                    disabledDate: time => {
                        let beginDateVal = this.form.deadline;
                        if (beginDateVal) {
                            return (
                                time.getTime() <
                                new Date(beginDateVal).getTime()
                            );
                        }
                    },
            },
            payTypes:[
                {
                    value: '年',
                    label: '年' 
                },
                {
                    value: '月',
                    label: '月' 
                },
                {
                    value: '日',
                    label: '日' 
                },
            ],
            dialogVisible:false,
            xueLis:[
                   {
                    value: '小学',
                    label: '小学'
                },{
                    value: '初中',
                    label: '初中'
                },{
                    value: '高中',
                    label: '高中'
                },{
                    value: '专科',
                    label: '专科'
                },{
                    value: '本科',
                    label: '本科'
                },{
                    value: '研究生',
                    label: '研究生'
                },{
                    value: '博士生',
                    label: '博士生'
                },{
                    value: '其他',
                    label: '其他'
                }
            ],
            xingBies:[
                {
                    value: '',
                    label: '不限'
                },{
                    value: 'true',
                    label: '男'
                },{
                    value: 'false',
                    label: '女'
                }
            ],
            active:1,
            zhiWeis:[],
            gongZhongs:[],
            labelPosition: 'right',
            step1Rules:{
                professionId:[
                    {
                         required: true,message: '请选择工种', trigger: 'change'
                    }
                ],
                positionId:[
                    {
                        required: true,message: '请选择职位', trigger: 'change'
                    }
                ],
                requirePopulation:[
                    {
                        required: true,message: '请输入委培人数', trigger: 'blur'
                    }
                ],
                contact:[
                    {
                        required: true,message: '请输入联系方式', trigger: 'blur'
                    },
                    {
                         validator: validateContact,trigger:'blur'
                    }
                ],
                address:[
                    {
                        required: true,message: '请输入工作地址', trigger: 'blur'
                    },
                    {
                         validator: validateInformation,trigger:'blur'
                    }
                ],
                minSalary:[
                    {
                        required: true,message: '请输入工资水平', trigger: 'blur'
                    }
                ],
                dateTime1:[
                    {
                        required: true,message: '请选择委培时间', trigger: 'blur'
                    }
                ],
                deadline:[
                    {
                        required: true,message: '请选择截止时间', trigger: 'blur'
                    }
                ],
                applyRequest:[
                    {
                        required: true,message: '请输入报名要求', trigger: 'blur'
                    },
                    {
                         validator: validateInformation,trigger:'blur'
                    }
                ],
                otherNotice:[
                    {
                        required: true,message: '请输入其他说明', trigger: 'blur'
                    },
                    {
                         validator: validateNotice,trigger:'blur'
                    }
                ],
            },
            step2Rules:{
                baseSalary:[
                    {
                        required: true,message: '请输入基本工资', trigger: 'blur'
                    }
                ],
                paySalaryDate:[
                    {
                        required: true,message: '请输入发薪日期', trigger: 'blur'
                    }
                ],
                payType:[
                    {
                        required: true,message: '请选择结算方式', trigger: 'change'
                    }
                ],
                salaryOtherNotice:[
                    {
                        required: true,message: '请输入其他说明', trigger: 'blur'
                    },
                    {
                         validator: validateNotice,trigger:'blur'
                    }
                ],
            },
            step3Rules:{
                liveNotice:[
                    {
                        required: true,message: '请输入住宿说明', trigger: 'blur'
                    },
                    {
                         validator: validateInformation,trigger:'blur'
                    }
                ],
                foodNotice:[
                    {
                        required: true,message: '请输入饮食说明', trigger: 'blur'
                    },
                    {
                         validator: validateInformation,trigger:'blur'
                    }
                ],
                socialSecurityNotice:[
                    {
                        required: true,message: '请输入社保说明', trigger: 'blur'
                    },
                    {
                         validator: validateInformation,trigger:'blur'
                    }
                ],
                liveFoodOtherNotice:[
                    {
                        required: true,message: '请输入其他说明', trigger: 'blur'
                    },
                    {
                         validator: validateNotice,trigger:'blur'
                    }
                ],
            },
            step4Rules:{
                jobText:[
                    {
                        required: true,message: '请输入工作内容', trigger: 'blur'
                    },
                    {
                         validator: validateInformation,trigger:'blur'
                    }
                ],
                postTime:[
                    {
                        required: true,message: '请输入工作时间', trigger: 'blur'
                    }
                ],
                jobWay:[
                    {
                        required: true,message: '请输入工作方式', trigger: 'blur'
                    },
                    {
                         validator: validateInformation,trigger:'blur'
                    }
                ],
                jobOtherNotice:[
                    {
                        required: true,message: '请输入其他说明', trigger: 'blur'
                    },
                    {
                         validator: validateNotice,trigger:'blur'
                    }
                ],
            },
            step5Rules:{
                
                minAgeRequest:[
                    {
                        required: true,message: '请输入年龄条件', trigger: 'change'
                    }
                ],
                eduBackground:[
                    {
                        required: true,message: '请选择学历条件', trigger: 'change'
                    }
                ],
                minExpRequest:[
                    {
                        required: true,message: '请输入经验条件', trigger: 'blur'
                    }
                ],
                credentialRequest:[
                    {
                        required: true,message: '请输入证书条件', trigger: 'blur'
                    },
                    {
                         validator: validateInformation,trigger:'blur'
                    }
                ],
                employOtherNotice:[
                    {
                        required: true,message: '请输入其他说明', trigger: 'blur'
                    },
                    {
                         validator: validateNotice,trigger:'blur'
                    }
                ],
            },
            form: {
                //基本信息
                professionId:'',
                positionId:'',
                requirePopulation:10,
                contact:'',
                address:'',
                minSalary:1000,
                maxSalary:4000,
                startTime:'',
                endTime:'',
                deadline:'',
                applyRequest:'',
                otherNotice:'',
                //工资待遇
                baseSalary:3000,
                paySalaryDate:1,
                payType:'月',
                salaryOtherNotice:'',
                //住宿饮食
                liveNotice:'',
                foodNotice:'',
                socialSecurityNotice:'',
                liveFoodOtherNotice:'',
                //岗位要求
                jobText:'',
                jobTimeNotice:'',
                
                //时间处理
                dateTime1:[],
                postTime:[new Date(2019,9, 10, 8, 40), new Date(2019,9, 10, 9, 40)],
                startTime1:'08:00',
                endTime1:'18:00',

                jobWay:'',
                jobOtherNotice:'',
                //录用条件
                sexRequest:'',
                minAgeRequest:18,
                maxAgeRequest:40,
                eduBackground:'',
                credentialRequest:'',
                employOtherNotice:'',
                minExpRequest:0,
                maxExpRequest:10,
        },
        tempId:'',
        }
    },
    mounted(){
        this.getGongZhong();
        this.isSaved();
    },
    methods:{
        // 时间开始选择器
            startTimeStatus:function(value){
                this.form.deadline = value
            },
            // 时间结束选择器
            endTimeStatus:function(value){
                this.form.startTime = value
            },

        isSaved(){
            var URL='http://47.101.180.43:8075/consign/consignSaved'
                        this.$ajax({
                        method:'get',
                        url:URL,
                    }).then(response =>{
                        var code=0;
                        code=response.data.code;
                        if(code==0){
                            this.dialogVisible=true;
                        }
                    }).catch(error => {
                    console.log('获取是否保存失败');
                    });

        },
        correctTime1(){
            console.log(this.form.postTime);
            this.form.startTime1=this.form.postTime[0];
            this.form.endTime1=this.form.postTime[1];
            this.form.jobTimeNotice=this.form.startTime1+'-'+this.form.endTime1;
            console.log(this.form.jobTimeNotice);
        },
        correctTime(){
            console.log(this.form.dateTime1);
            this.form.startTime=this.form.dateTime1[0];
            console.log(this.form.startTime);
            this.form.endTime=this.form.dateTime1[1];
            console.log(this.form.endTime);

        },
        getGongZhong(){
            var URL='http://47.101.180.43:8075/visitor/getProfessionInformation'
                        this.$ajax({
                        method:'get',
                        url:URL,
                    }).then(response =>{
                        var code=0;
                        code=response.data.code;
                        if(code==0){
                            console.log(response.data.data.professionInformation); 
                            this.gongZhongs=response.data.data.professionInformation;
                            console.log(this.gongZhongs);
                        }else{
                            console.log(response.data.msg); 
                            this.$notify({
                                message:response.data.msg
                            });
                        }
                    }).catch(error => {
                    console.log('职业种类获取失败');
                    });
        },
        editSaved(){
            this.getSavedConsign();
            this.dialogVisible=false;
        },
        showTime(){
            console.log('这'+this.form.startTime);
        },
        getSavedConsign(){
            var URL='http://47.101.180.43:8075/consign/consignSaved'
                        this.$ajax({
                        method:'get',
                        url:URL,
                    }).then(response =>{
                        var code=0;
                        code=response.data.code;
                        if(code==0){
                            console.log(response.data.msg); 
                            this.form=response.data.data;
                            this.tempId=this.form.positionId;
                            this.getPosition();
                            this.form.positionId=this.tempId;
                            console.log(this.form.dateTime1);
                            console.log('保存的时间'+this.form.jobTimeNotice);
                            this.form.postTime=this.form.jobTimeNotice.split("-");
                           
                        }else{
                            console.log(response.data.msg); 
                            this.$notify({
                                message:response.data.msg
                            });
                        }
                    }).catch(error => {
                    console.log('委培保存信息获取失败');
                    });
        },
        tiJiao(){
            this.$refs['form'].validate((valid) => {
            if (valid) {
            console.log(this.form);
            var URL='http://47.101.180.43:8075/consign/consignRelease'
                        this.$ajax({
                        method:'put',
                        url:URL,
                        params:{
                            positionId:this.form.positionId,
                            requirePopulation:this.form.requirePopulation,
                            contact:this.form.contact,
                            address:this.form.address,
                            minSalary:this.form.minSalary,
                            maxSalary:this.form.maxSalary,
                            startTime:this.form.startTime,
                            endTime:this.form.endTime,
                            deadline:this.form.deadline,
                            applyRequest:this.form.applyRequest,
                            otherNotice:this.form.otherNotice,
                            baseSalary:this.form.baseSalary,
                            paySalaryDate:this.form.paySalaryDate,
                            payType:this.form.payType,
                            salaryOtherNotice:this.form.salaryOtherNotice,
                            liveNotice:this.form.liveNotice,
                            foodNotice:this.form.foodNotice,
                            socialSecurityNotice:this.form.socialSecurityNotice,
                            liveFoodOtherNotice:this.form.liveFoodOtherNotice,
                            jobText:this.form.jobText,
                            jobTimeNotice:this.form.jobTimeNotice,
                            jobWay:this.form.jobWay,
                            jobOtherNotice:this.form.jobOtherNotice,
                            sexRequest:this.form.sexRequest,
                            minAgeRequest:this.form.minAgeRequest,
                            maxAgeRequest:this.form.maxAgeRequest,
                            eduBackground:this.form.eduBackground,
                            credentialRequest:this.form.credentialRequest,
                            employOtherNotice:this.form.employOtherNotice,
                            minExpRequest:this.form.minExpRequest,
                            maxExpRequest:this.form.maxExpRequest,
                        },
                    }).then(response =>{
                        var code=0;
                        code=response.data.code;
                        if(code==0){
                            console.log(response.data.data); 
                            this.$notify({
                                message: response.data.data,
                                type: 'success'
                            });
                            this.active=1;
                            this.form={};
                            this.$router.push({
                                path:'/companyPage/home/showConsign',
                            })
                        }else{
                            console.log(response.data.msg); 
                            this.$notify({
                                message: response.data.msg,
                            });
                        }
                    }).catch(error => {
                            console.log('提交失败');
                    })
                }else {
                    console.log('error submit!!');
                }
            });
        },
        baoCun(){
            console.log(this.form);
            if(this.form.jobTimeNotice==''){
                this.form.jobTimeNotice='08:00-18:00';
                console.log('这里是没有选择时的时间：'+this.form.jobTimeNotice);
            }
            var URL='http://47.101.180.43:8075/consign/consignSave'
                        this.$ajax({
                        method:'post',
                        url:URL,
                        data:this.form,
                    }).then(response =>{
                        console.log(this.form);
                        var code=0;
                        code=response.data.code;
                        if(code==0){
                            console.log(response.data.data); 
                            this.$notify({
                                message: response.data.data,
                                type: 'success'
                            });
                        }else{
                            console.log(response.data.msg); 
                            this.$notify({
                                message: response.data.msg,
                            });
                        }
                    }).catch(error => {
                    console.log('保存失败');
                    });
        },
        getPosition(){
            console.log('这里是工种'+this.form.professionId);
            this.form.positionId='';
            this.zhiWeis=[];
            var URL='http://47.101.180.43:8075/post/conditionIdGetPosition'
                        this.$ajax({
                        method:'get',
                        url:URL,
                        params:{
                            id:this.form.professionId,
                        },
                    }).then(response =>{
                        var code=0;
                        code=response.data.code;
                        if(code==0){
                            console.log(response.data.msg); 
                            this.zhiWeis=response.data.data;
                        }else{
                            console.log(response.data.msg); 
                            this.$notify({
                                message:response.data.msg
                            });
                        }
                    }).catch(error => {
                    console.log('职位获取失败');
                    });
        },
       back(){
            if(this.active==1){
                console.log('已经是最后一步了');
            }else{
                this.active--;
            }
        },
        goToStep2(){
            this.$refs['form'].validate((valid) => {
            if (valid) {
                this.active=2;
                }else {
                    console.log('error submit!!');
            }
            });
        },
        goToStep3(){
            this.$refs['form'].validate((valid) => {
            if (valid) {
                this.active=3;
                }else {
                    console.log('error submit!!');
            }
            });
        },
        goToStep4(){
            this.$refs['form'].validate((valid) => {
            if (valid) {
                this.active=4;
                }else {
                    console.log('error submit!!');
            }
            });
        },
        goToStep5(){
            this.$refs['form'].validate((valid) => {
            if (valid) {
                this.active=5;
                }else {
                    console.log('error submit!!');
            }
            });
        },
        goToStep5(){
            this.$refs['form'].validate((valid) => {
            if (valid) {
                this.active=5;
                }else {
                    console.log('error submit!!');
            }
            });
        },
        goToStep6(){
            this.$refs['form'].validate((valid) => {
            if (valid) {
                    this.$notify({
                        message:"支付功能还未开放！",
                    });
                }else {
                    console.log('error submit!!');
            }
            });
        },
    }
}
</script>

<style>
.consginDate .el-input__inner{
    padding-left:30px;
}

.diBuAnNiu2{
    position:absolute;
    bottom:0px;
    left:300px;
}
.diBuAnNiu{
    position:absolute;
    bottom:0px;
    left:360px;
}
.guiZe{
    position: absolute;
    bottom: 20px;
    right:40px;
}
.juZhong{
    display:flex;
    align-items:center;
    justify-content:center
}
.xinZengBox2{
    left: 50%;
    margin-left: -400px;
    width:800px;
    height:820px;
    /* background-color: #4A4C5B; */
    position: absolute;
}
.mainBox2{
    position: relative;
    min-height: 950px;
	background-color: #FFFFFF;
	margin-top: 20px;
	padding: 20px;
	border-radius: 10px;
}
</style>